package com.unionfetch.content_home.model

import com.unionfetch.content_home.api.HomeApiManager
import com.unionfetch.content_home.bean.AccountCategory
import com.unionfetch.content_home.bean.TradeDataDetail
import com.unionfetch.content_home.contract.HomeContract
import com.unionftech.common.base.mvp.impl.BaseModel
import com.unionftech.common.base.mvp.impl.IBaseCallBack
import com.unionftech.common.bean.ResponseResult

class HomeModel : BaseModel(), HomeContract.IHomeModel {
    override fun getTradeDataDetail(
        token: String,
        tradeNo: String,
        category: AccountCategory,
        callBack: IBaseCallBack<ResponseResult<TradeDataDetail>>
    ) {
        execute {
            val result = request {
                if (category == AccountCategory.LIVE) {
                    HomeApiManager.getInstance().apiHome().getLiveTradeDataDetail(token, tradeNo)
                } else {
                    HomeApiManager.getInstance().apiHome().getDemoTradeDataDetail(token, tradeNo)
                }
            }
            callBack.onResponse(result)
        }
    }

    override fun getFloatSurplus(
        token: String, tradeNo: String, type: Int, callBack: IBaseCallBack<ResponseResult<String>>
    ) {
        execute {
            val result = request {
                HomeApiManager.getInstance().apiHome().getFloatSurplus(token, tradeNo, type)
            }
            callBack.onResponse(result)
        }
    }
}